<include file="public@header">
<body>
    <div class="bgbg headhead">
        <h3 class="mytitle">{:lang('Withdraw Address')}</h3>
        <div class="addressall">
            <foreach name="list" item="vo">
            <div class="addressshow">
                <p class="addressshowp1">
                    <span>USDT</span>{$vo.remark}
                    <a class="delete" data-id="{$vo.id}">
                        <img src="__STATIC__/hybit/images/delete.png" alt="">
                    </a>
                    <a href="{:url('user/address/edit',array('id'=>$vo.id))}">
                        <img src="__STATIC__/hybit/images/bianji1.png" alt="">
                    </a>
                </p>
                <div class="addressshow2">
                    <input type="text" value="{$vo.address}">
                    <p onclick="CopyUrl(this)"><img src="__STATIC__/hybit/images/fuzhi1.png" alt="">{:lang('Copy')}</p>
                </div>
            </div>
            </foreach>
        </div>
        <a href="{:url('user/address/add')}"><button class="emailbtn">{:lang('Add')}</button></a>
    </div>
    
    <script src="__STATIC__/hybit/js/jquery.min.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script>
    layui.use('layer',function(){
        var layer = layui.layer;

        $('.delete').click(function(){
            var id = $(this).data('id');
            layer.confirm('{:lang("Are you sure you want to delete it")}？', {
                title: '{:lang("Prompt")}',
                btn: ['{:lang("Confirm")}','{:lang("Cancel")}'] //按钮
            }, function(){
                $.ajax({
                    type: 'get',
                    url: '{:url("user/address/delete")}',
                    data: {id:id},
                    success:function(res){
                        layer.msg(res.msg);
                        if(res.code == 1){
                            setTimeout(function(){ location.reload(); }, 1500);
                        }
                    }
                });
                
            });
        });
    });


        function CopyUrl(obj) {
            let url = $(obj).siblings('input')[0];
            console.log(url)
            url.select();
            document.execCommand("Copy");
        }
    </script>
</body>
</html>